﻿@using WebShop.Infrastructure

@model IEnumerable<WebShop.Contracts.Category>

@{
    ViewBag.Title = "Categories";
}

<h2>Categories</h2>

<p>
    @if (User.IsInRole(Constants.ROLE_ADMIN))
    {
         @Html.ActionLink("Create New", "Create")
    }
</p>


@foreach (var item in Model) {
    <div class="category-block">
        <div class="category-header">  
            @Html.ActionLink(item.CategoryName, "Index", "Products", new { CategoryID = item.CategoryID }, new { title = "View products" })     
        </div>

        <a href='@Url.Action("Index", "Products", new { CategoryID = item.CategoryID })' title="View products">
            @Html.Image("Image", item.CategoryID.ToString(), new { @class = "category-image", alt = "View products" })
        </a>


        @if (User.IsInRole(Constants.ROLE_ADMIN))
        {            
            @Html.ActionLink("Edit", "Edit", new { id = item.CategoryID })
            @Html.Label("|") 
            @Html.ActionLink("Delete", "Delete", new { id = item.CategoryID })
            <br/>            
        }
    
    
        @Html.DisplayFor(modelItem => item.Description)
    
    </div>
}
